package basics.files;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

public class ReadFileToString {
	
	public static String getFileContents(String fileName) throws Exception {
	    File theFile = new File(fileName);
	    byte[] bytes = new byte[(int) theFile.length()];
	    InputStream in = new FileInputStream(theFile);
	    int m = 0, n = 0;
	    while (m < bytes.length) {
		n = in.read(bytes, m, bytes.length - m);
		m += n;
	    }
	    in.close();
	    
	    // using default encoding, this is probably what BufferedReader.readLine does anyway
	    return new String(bytes); 
	}

}
